/*
 * Copyright 2011 Vlad Goldman.  All rights reserved.
  
   This file is part of GooOutSync - Google Outlook Sync application
  
    Project page: http://goooutsync.googlecode.com

    GooOutSync is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    GooOutSync is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with GooOutSync.  If not, see <http://www.gnu.org/licenses/>.
 */

package com.vgold.goooutsync;

import java.util.prefs.Preferences;

public class GooOutSyncPreferences {
	public enum Prefs {
		time_between_sync, google_username, google_password, show_popups, proxy_server, proxy_port, proxy_user, proxy_password,
		outlook_silent_delete, google_silent_delete
	}

	private static GooOutSyncPreferences ref;
	private Preferences prefs;

	private GooOutSyncPreferences() {
		// prefs = Preferences.userRoot().node(this.getClass().getName());
		prefs = Preferences.userNodeForPackage(GooOutSync.class);
	}

	public synchronized String getPreference(Prefs prefID) {
		String prefDefault = "";
		switch (prefID) {
		case time_between_sync:
			prefDefault = "60";
			break;
		case show_popups:
			prefDefault = "true";
			break;
		case outlook_silent_delete:
			prefDefault = "false";
			break;
		case google_silent_delete:
			prefDefault = "false";
			break;
		}

		return prefs.get(prefID.toString(), prefDefault);

	}

	public synchronized void setPreference(Prefs prefID, String value) {
		prefs.put(prefID.toString(), value);
	}

	public static GooOutSyncPreferences getGooOutSyncPreferences() {
		if (ref == null)
			ref = new GooOutSyncPreferences();
		return ref;
	}

	public Object clone() throws CloneNotSupportedException {
		throw new CloneNotSupportedException();
	}
}
